/*
 * keyboard.h
 *
 *  Created on: 2016-10-25
 *      Author: m
 */

#ifndef SRC_INCLUDE_KERNEL_KEYBOARD_H_
#define SRC_INCLUDE_KERNEL_KEYBOARD_H_
#include "type.h"
#include "tty.h"

/*
 * Event types
 */
#define EV_KEY          0x00 //key down(press)
#define EV_REL          0x80 //key release(up)


#define KEY_RESERVED    0
#define KEY_A             (1)
#define KEY_B             (2)
#define KEY_C             (3)
#define KEY_D             (4)
#define KEY_E             (5)
#define KEY_F             (6)
#define KEY_G             (7)
#define KEY_H             (8)
#define KEY_I             (9)
#define KEY_J             (10)
#define KEY_K             (11)
#define KEY_L             (12)
#define KEY_M             (13)
#define KEY_N             (14)
#define KEY_O             (15)
#define KEY_P             (16)
#define KEY_Q             (17)
#define KEY_R             (18)
#define KEY_S             (19)
#define KEY_T             (20)
#define KEY_U             (21)
#define KEY_V             (22)
#define KEY_W             (23)
#define KEY_X             (24)
#define KEY_Y             (25)
#define KEY_Z             (26)
#define KEY_0             (27)
#define KEY_1             (28)
#define KEY_2             (29)
#define KEY_3             (30)
#define KEY_4             (31)
#define KEY_5             (32)
#define KEY_6             (33)
#define KEY_7             (34)
#define KEY_8             (35)
#define KEY_9             (36)
#define KEY_GRAVE         (37)
#define KEY_MINUS         (38)
#define KEY_EQUAL         (39)
#define KEY_BACKSLASH     (40)
#define KEY_BACKSPACE     (41)
#define KEY_SPACE         (42)
#define KEY_TAB           (43)
#define KEY_CAPSLOCK      (44)
#define KEY_LEFTSHIFT     (45)
#define KEY_LEFTCTRL      (46)
#define KEY_LEFT_WIN      (47)
#define KEY_LEFTALT       (48)
#define KEY_RIGHTSHIFT    (49)
#define KEY_RIGHTCTRL     (50)
#define KEY_RIGHT_WIN     (51)
#define KEY_RIGHTALT      (52)
#define KEY_MENU          (53)
#define KEY_ENTER         (54)
#define KEY_ESC           (55)
#define KEY_F1            (56)
#define KEY_F2            (57)
#define KEY_F3            (58)
#define KEY_F4            (59)
#define KEY_F5            (60)
#define KEY_F6            (61)
#define KEY_F7            (62)
#define KEY_F8            (63)
#define KEY_F9            (64)
#define KEY_F10           (65)
#define KEY_F11           (66)
#define KEY_F12           (67)
#define KEY_PRINT_SCREEN  (68)
#define KEY_SCROLLLOCK    (69)
#define KEY_PAUSE         (70)
#define KEY_LEFTBRACE     (71)
#define KEY_INSERT        (72)
#define KEY_HOME          (73)
#define KEY_PAGEUP        (74)
#define KEY_DELETE        (75)
#define KEY_END           (76)
#define KEY_PAGEDOWN      (77)
#define KEY_UP            (78)
#define KEY_LEFT          (79)
#define KEY_DOWN          (80)
#define KEY_RIGHT         (81)
#define KEY_NUMLOCK       (82)
#define KEY_KPSLASH       (83)
#define  KEY_KPASTERISK   (84)
#define KEY_KPMINUS       (85)
#define KEY_KPPLUS        (86)
#define KEY_KPENTER       (87)
#define KEY_KPDOT         (88)
#define KEY_KP0           (89)
#define KEY_KP1           (90)
#define KEY_KP2           (91)
#define KEY_KP3           (92)
#define KEY_KP4           (93)
#define KEY_KP5           (94)
#define KEY_KP6           (95)
#define KEY_KP7           (96)
#define KEY_KP8           (97)
#define KEY_KP9           (98)
#define KEY_RIGHTBRACE    (99)
#define KEY_SEMICOLON     (100)
#define KEY_APOSTROPHE    (101)
#define KEY_COMMA         (102)
#define KEY_DOT           (103)
#define KEY_SLASH         (104)

typedef struct {
    char* str_key;
    char* str_key_shift_up;
    u8 make_code;
    u8 vkey;
} KEY_INFO;
extern KEY_INFO skey_info[];

extern void init_keyboard();
extern void keyboard_handler(int irq_no);
extern void keyboard_read(Q* dest_q);

#endif /* SRC_INCLUDE_KERNEL_KEYBOARD_H_ */
